﻿using System.Windows;
using Microsoft.Win32;

namespace MPlayer.DotNet.WPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            Loaded += MainWindowLoaded;
            Closing += MainWindowClosing;
        }

        static void MainWindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            MPlayerContext.CloseAll();
        }

        void MainWindowLoaded(object sender, RoutedEventArgs e)
        {
            MPlayerContext.ExecutablePath = "player";
            MPlayerContext.Initialize((int)mPlayerWPFControl1.Handle);
        }

        private void ButtonClick(object sender, RoutedEventArgs e)
        {
            var dlg = new OpenFileDialog
            {
                FileName = "Document",
                Filter = "All files (*.*)|*.*"
            };

            // Show open file dialog box
            bool? result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                MPlayerContext.OpenFile(dlg.FileName);
            }
        }
    }
}
